// 网络交互 网络程的过滤器
import axios from 'axios'
const catchNetwork = axiosPromise => new Promise((resolve, reject) => {
  axiosPromise.then(response => resolve(response))
    .catch(error => { reject(error) })
})

// 构造函数
export default class Fetch {
  constructor (path) {
    this.path = path
    this.axios = axios
  }
  // 192.168.0.1:3000 1级
  // xxapi  2级
  // get 请求  3级
  getServerDate (subPath, param) {
    return catchNetwork(
      this.axios.get(`${this.path}${subPath}?${param}`)
    )
  }
  // addItem
  // deleteItem
  // pu
}
